home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / PRBitmap.h < prev    next >
Encoding:
Text File  |  1996-04-25  |  4.8 KB  |  186 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PRBitmap.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef PRBITMAP_H
  11. #define PRBITMAP_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #ifndef SLGRDEF_H
  18. #include "SLGrDef.h"
  19. #endif
  20.  
  21. #ifndef SLPTRECT_H
  22. #include "SLPtRect.h"
  23. #endif
  24.  
  25. #ifndef PRGRREF_H
  26. #include "PRGrRef.h"
  27. #endif
  28.  
  29. #ifndef SLPALETE_H
  30. #include "SLPalete.h"
  31. #endif
  32.  
  33. #ifndef SLPICTUR_H
  34. #include "SLPictur.h"
  35. #endif
  36.  
  37. //========================================================================================
  38. //    Forward Declarations
  39. //========================================================================================
  40.  
  41. class FW_OResourceFile;
  42.  
  43. class FW_CReadableStream;
  44. class FW_CWritableStream;
  45.  
  46. struct FW_SGraphicContext;
  47.  
  48. //========================================================================================
  49. //    class FW_CPrivBitmapRep
  50. //========================================================================================
  51.  
  52. class FW_CPrivBitmapRep : public FW_CPrivGrRefObj
  53. {
  54. public:
  55.     FW_DECLARE_AUTO(FW_CPrivBitmapRep)
  56.  
  57.     // ----- Construction -----
  58.                             FW_CPrivBitmapRep(
  59.                                 short width,  short height,
  60.                                 short pixelSize, FW_Palette palette,
  61.                                 void* image, long imageSize, short rowBytes);
  62.  
  63.                             FW_CPrivBitmapRep(FW_PlatformBitmap platformBitmap);
  64.  
  65.                             FW_CPrivBitmapRep(FW_OResourceFile* resourceFile, FW_ResourceId resId);
  66.  
  67.                             FW_CPrivBitmapRep(const FW_CPrivBitmapRep& bitmap, const FW_SRect& srcRect);
  68.                             
  69.                             ~FW_CPrivBitmapRep();
  70.  
  71.     // ----- Common operations -----
  72.     FW_Boolean                IsEqual(const FW_CPrivBitmapRep& bitmap) const;
  73.     
  74.     // ----- Streaming -----
  75.  
  76.     void                    Write(FW_CWritableStream& stream, FW_Boolean bDIBFileHeader);
  77.                             FW_CPrivBitmapRep(FW_CReadableStream& stream, FW_Boolean bDIBFileHeader);
  78.  
  79.     // ----- Handle operations -----
  80.     
  81.     FW_PlatformBitmap        GetPlatformBitmap() const;
  82.     FW_Boolean                IsPlatformBitmapOrphan() const;
  83.     FW_PlatformBitmap        OrphanPlatformBitmap();
  84.     
  85.     void                    SetPlatformBitmap(FW_PlatformBitmap newBitmap);
  86.     void                    AdoptPlatformBitmap(FW_PlatformBitmap newBitmap);
  87.  
  88.     // ----- Palette -----
  89.     
  90.     FW_Palette                GetPalette() const; 
  91.     void                    SetPalette(FW_Palette palette);
  92.  
  93.     // ----- Bitmap info -----
  94.  
  95.     void                    GetBitmapInfo(short& width, short& height, 
  96.                                       short& rowBytes, short& pixelSize) const;
  97.  
  98.     void                    GetBitmapBoundsGC(Environment* ev, FW_SGraphicContext& gc, FW_SRect& bounds) const;
  99.     void                    GetBitmapBounds(FW_SRect& bounds) const;
  100.  
  101.     // ----- Changing the bitmap -----
  102.     
  103.     FW_PlatformError        ChangeBitmap(short width, 
  104.                                         short height, 
  105.                                         short pixelSize,
  106.                                         FW_Boolean bScale);
  107.     FW_PlatformError        ChangeBitmap(void* image, 
  108.                                         long imageSize, 
  109.                                         short rowBytes,
  110.                                         short width, 
  111.                                         short height, 
  112.                                         short pixelSize,
  113.                                         FW_Boolean bScale);                                
  114.     FW_PlatformError        SetImage(void* image, long imageSize, short rowBytes);
  115.  
  116.     // ----- Copy Pixels -----
  117.  
  118.     FW_PlatformError        CopyPixels(FW_CPrivBitmapRep& dstBitmap, 
  119.                                         const FW_SRect& boundsSrc, 
  120.                                         const FW_SRect& boundsDst) const;
  121.  
  122. #ifdef FW_BUILD_MAC
  123.  
  124.     // ----- Conversion -----
  125.  
  126.                             FW_CPrivBitmapRep(FW_HPicture picture,
  127.                                 FW_SColor fillColor, const FW_SRect& pictPart);
  128.  
  129.     FW_HPicture                MacGetAsPicture(const FW_SRect& bounds) const;
  130. #endif
  131.  
  132.     // ----- Mac Lock/Unlock -----
  133. #ifdef FW_BUILD_MAC
  134.     PixMapHandle            MacLockPixels();
  135.     void                    MacUnlockPixels();
  136.     FW_Boolean                MacIsPixelsLocked() const;
  137. #endif
  138.  
  139.     // ----- Implementation
  140. private:
  141.     void                    PrivDisposeBitmap();
  142.     void                    PrivMakeBitmap(short width, short height,
  143.                                 short pixelSize, FW_Palette palette);
  144.     void                    PrivReadFromStream(FW_CReadableStream& stream, FW_Boolean bDIBFileHeader);
  145.  
  146.     FW_Boolean                fOwnBitmap;
  147.     FW_PlatformBitmap        fPlatformBitmap;
  148.  
  149. #ifdef FW_BUILD_MAC
  150.     short                     fLockCount;
  151.     PixMapHandle            fPixMapHandle;
  152. #endif
  153. #ifdef FW_BUILD_WIN
  154.     // Windows GDI can only work with DDBs of two color depths: monochrome and whatever the
  155.     //    current display setting is.  But the user can ask for an aribtrary color depth!
  156.     //    To solve this, I have to remember the requested color depth and use what GDI can do
  157.     short                    fUserColorDepth;
  158.     FW_Palette                fWinPalette;
  159. #endif
  160. };
  161.  
  162. #ifdef FW_BUILD_MAC
  163.  
  164. //========================================================================================
  165. // CLASS FW_CPrivMacPixelLock
  166. //========================================================================================
  167.  
  168. class FW_CPrivMacPixelLock
  169. {
  170. public:
  171.     FW_DECLARE_AUTO(FW_CPrivMacPixelLock)
  172.  
  173.                     FW_CPrivMacPixelLock(FW_HBitmap);
  174.                     ~FW_CPrivMacPixelLock();
  175.  
  176.     PixMapHandle    GetPixMapHandle() const;
  177.     
  178. private:
  179.     FW_HBitmap        fBitmap;
  180.     PixMapHandle    fPixMapHandle;
  181. };
  182.  
  183. #endif
  184.  
  185. #endif // PRBITMAP_H
  186.